import request from "@/utils/request";

enum API{
    GET_USER_LIST = "/admin/acl/user/",
    GET_USER_BYID = "/admin/acl/user/get/",
    GET_ROLE_BYUSERID = "/admin/acl/user/toAssign/",
    ADD_USER = "/admin/acl/user/save",
    UPDATE_USER = "/admin/acl/user/update",
    DELETE_USER_BYID = "/admin/acl/user/remove/",
    DELETE_USER_BYIDS = "/admin/acl/user/batchRemove",
    UPDATE_ROLE_BYUSER = "/admin/acl/user/doAssignRole"
}

export const getUserList = (page:number,limit:number,username:string,name:string) => request.get(API.GET_USER_LIST+page+'/'+limit,{params:{username,name}});
export const getUserById = (id:number) => request.get(API.GET_USER_BYID+id);
export const getRoleByUserId = (adminId:number) => request.get(API.GET_ROLE_BYUSERID+adminId);
export const addUser = (user:unknown) => request.post(API.ADD_USER,user);
export const updateUser = (user:unknown) => request.put(API.UPDATE_USER,user);
export const deleteUserById = (id:number) => request.delete(API.DELETE_USER_BYID+id);
export const deleteUserByIdList = (idList:number[]) => request.delete(API.DELETE_USER_BYIDS,{data:idList});
export const updateRoleByUser = (roleVo:unknown) => request.post(API.UPDATE_ROLE_BYUSER,roleVo);

export default{
    getUserList,
    getUserById,
    getRoleByUserId,
    addUser,
    updateUser,
    deleteUserById,
    deleteUserByIdList,
    updateRoleByUser
}